export default {
  install(Vue, options) {
      Vue.prototype.ajaxUrl = 'weixinservice.ashx',
      Vue.prototype.loadUrl = 'CometAsyncHandler.ashx',
      Vue.prototype.jajaxUrl = 'http://syappeal.eheat.com.cn/weixinservice.ashx',
      Vue.prototype.jloadUrl = 'http://syappeal.heatingpay.com/handler/CometAsyncHandler.ashx',
      Vue.prototype.jholdUrl = 'http://syappeal.heatingpay.com/handler/AccessCoreService.ashx',
      Vue.prototype.commondurl = 'http://www.heatingpay.com/command.ashx',
      Vue.prototype.unique = function(arr){ //数组去重
          var tmp = new Array();
          for (var i in arr) {
              if (tmp.indexOf(arr[i]) == -1) {
                  tmp.push(arr[i]);
              }
          }
          return tmp;
      },
      Vue.prototype.post = (url, data, successfun, errorfun) => {
        let arrayAJAX = new Array();
        arrayAJAX.push($.ajax({
          type: "POST",
          url: url,
          dataType: "json",
          contentType: "application/x-www-form-urlencoded;charset=UTF-8",
          data: data,
          timeout: 20000000,
          success: function(e) {
            successfun(e);
          },
          error: function(e) {
            console.log('lost')
          }
        }));
      },
      Vue.prototype.get = function(url) {
        arrayAJAX.push($.ajax({
          type: "GET",
          url: url,
          dataType: "json",
          contentType: "application/x-www-form-urlencoded;charset=UTF-8",
          data: data,
          timeout: 20000,
          success: function(e) {
            if (e === null) {
              //hideLoadingPage();
              //alert("你的网络不太给力哟！");
              return;
            }
            successfun(e);
          },
          error: function(e) {
            //hideLoadingPage();
            errorfun(e)
          },
          beforeSend: function(e) {},
          complete: function(e) {
            //hideLoadingPage();
          }
        }));
      }
  }
}
